import request from "../utils/request";
import requestFile from "../utils/requestFile";

// 获取用户数据
export const getUserApi = (query) => {
    // console.log('query',query);
    return request('/user', {
        method: 'get',
        query: {
            pageSize: 10,
            pageNum: 1,
            ...query
        }
    })
}

// 删除用户
export const delUserApi = (id) => {
    return request(`/user/${id}`, {
        method: 'delete'
    })
}

// 新增用户
export const addUserApi = (body) => {
    return request('/user', {
        method: 'post',
        body
    })
}

// 编辑用户
export const editUserApi = (body) => {
    return request('/user', {
        method: 'put',
        body
    })
}

// 获取角色
export const getRoleApi = (query) => {
    return request('/role', {
        method: 'get',
        query: {
            pageSize: 10,
            pageNum: 1,
            ...query
        }
    })
}

// 导出excel
export const downloadInfoApi = (param) => {
    return requestFile(`/${param}/excel`, {
        method: 'post',
        body: {
            filename: `${param}DataFile`
        }
    })
}

// 删除角色
export const delRoleApi =(id)=>{
    return request(`/role/${id}`,{
        method:'delete'
    })
}

// 获取某一角色的权限菜单
export const getRoleMenuApi = (id)=>{
    return request (`/role/menu/${id}`,{
        method:'get'
    })
}

// 新增角色
export const addRoleApi = (body)=>{
    return request('/role',{
        method:'post',
        body
    })
}

// 修改角色
export const editRoleApi = (body)=>{
    return request('/role',{
        method:'put',
        body
    })
}